package com.xidian.zhiancloud.controller.checkdanger;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.Page;
import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.enums.UserResponseEnums;
import com.xidian.zhiancloud.qo.BaseReqQuery;
import com.xidian.zhiancloud.service.checkdanger.ChkOrderService;

/**
 * 隐患排查清单
 */
@RestController
@RequestMapping("/chkorder")
public class ChkOrderController extends BaseController {
	
	@Autowired
	ChkOrderService chkorderService;

	/**
     *  -查询排查清单

	 * @param reqdata
	 * @param key     搜索关键字
     * @return 返回 ResultDTO 对象
     */
	@SuppressWarnings("rawtypes")
	@RequestMapping(value = "/getChkOrderList")
    public ResultDTO getChkOrderList(BaseReqQuery reqdata,
    		@RequestParam(value="key",required=false ,defaultValue="") String key)
    {
		Page<Map<String,String>> pagedata = chkorderService.getChkOrderList(reqdata,key);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("datalist", pagedata);
		data.put("PageNum", pagedata.getPageNum());
		data.put("PageSize", pagedata.getPageSize());
		data.put("PageTotal", pagedata.getPages());
		data.put("total", pagedata.getTotal());
		return ResultDTO.successOf(data, GeneralResponseEnums.SUCCESS);
    }
	
	/**
     *  -新增 清单类型

	 * @param id // 传送对应的ID
     * @param type 	// 类型
	 * @param typeids // 类型IDS
     * @return 返回 ResultDTO 对象
     */
	
	@SuppressWarnings({ "rawtypes" })
	@RequestMapping(value = "/insertChkOrderType")
	public ResultDTO insertChkOrderType(Integer id,Integer type,String typeids)
	{
		
		
		int rt = chkorderService.insertChkOrderType(id,type,typeids);
		if(rt!=1)
		{
			return ResultDTO.errorOf(UserResponseEnums.USER_PARAMETERS_ERROR);
		}
		
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  -修改　排查类清单类型

	 * @param id // 传送对应的ID
     * @param type 	// 类型
	 * @param typeids // 类型IDS
     * @return 返回 ResultDTO 对象
     */
	@SuppressWarnings({ "rawtypes" })
	@RequestMapping(value = "/updateChkOrderType")
	public ResultDTO updateChkOrderType(Integer id,Integer type,String typeids)
	{
	
		
		int rt = chkorderService.updateChkOrderType(id,type,typeids);
		//if(rt!=1)
		{
			//return ResultDTO.errorOf(UserResponseEnums.USER_PARAMETERS_ERROR);
		}
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  -查询 清单详细

	 * @param id // 传送对应的ID
     * @return 返回 ResultDTO 对象
     */
	@SuppressWarnings("rawtypes")
	@RequestMapping(value = "/getChkOrder3Detail")
    public ResultDTO getChkOrder3Detail(Integer id)
    {
		Map<String,String> rt = chkorderService.getChkOrder3Detail(id);
		
		return ResultDTO.successOf(rt, GeneralResponseEnums.SUCCESS);
    }
	
	/**
     *  -查询 清单详细

	 * id // 传送对应的ID
     * @return 返回 ResultDTO 对象
     */
	@SuppressWarnings("rawtypes")
	@RequestMapping(value = "/getChkOrder3Detailist")
    public ResultDTO getChkOrder3Detailist(Integer id)
    {
		List<Map<String,String>> rt = chkorderService.getChkOrder3Detailist(id);
		
		return ResultDTO.successOf(rt, GeneralResponseEnums.SUCCESS);
    }
	
}
